From: Florian Müllner Date: Sat, 14 Sep 2019 15:09:04 +0000 (+0200) Subject: ci: Make run-eslint more convenient for local use X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~781^2^2~513 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=d12cd12e1b8428c669c013036f6617c81f7477b7;p=gnome-shell.git ci: Make run-eslint more convenient for local use The script can be helpful outside of CI, in particular for gradually transitioning to the new style. Reverting commit f00201fa6ca it is already possible to do something like $ CI_MERGE_REQUEST_PROJECT_URL=https://gitlab.gnome.org/GNOME/gnome-shell \ CI_MERGE_REQUEST_TARGET_BRANCH_NAME=master CI_COMMIT_SHA=HEAD \ .gitlab-ci/run-eslint.sh but that is hardly convenient. Instead, allow passing the required parameters on the command line: $ .gitlab-ci/run-eslint.sh origin master https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/730 --- diff --git a/.gitlab-ci/run-eslint.sh b/.gitlab-ci/run-eslint.sh index edcdfc1fd..103ba9361 100755 --- a/.gitlab-ci/run-eslint.sh +++ b/.gitlab-ci/run-eslint.sh @@ -76,10 +76,13 @@ create_common() { # non-legacy style just yet ... unset CI_MERGE_REQUEST_TARGET_BRANCH_NAME -if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" ]; then - git fetch $CI_MERGE_REQUEST_PROJECT_URL.git $CI_MERGE_REQUEST_TARGET_BRANCH_NAME +REMOTE=${1:-$CI_MERGE_REQUEST_PROJECT_URL.git} +BRANCH_NAME=${2:-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME} + +if [ "$BRANCH_NAME" ]; then + git fetch $REMOTE $BRANCH_NAME branch_point=$(git merge-base HEAD FETCH_HEAD) - commit_range=$branch_point...$CI_COMMIT_SHA + commit_range=$branch_point...HEAD list_commit_range_additions $commit_range > $LINE_CHANGES @@ -102,7 +105,7 @@ if ! is_empty $OUTPUT_FINAL; then fi # Just show the report and succeed when not testing a MR -if [ -z "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" ]; then +if [ -z "$BRANCH_NAME" ]; then exit 0 fi